package com.uobgroup.ews.uam.core.domain;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.constraints.Size;

import org.springframework.beans.factory.annotation.Configurable;

@Entity
@Configurable
public class CombinationMatrix extends BaseEntity {

   public static final String COUNT_COMBINATION_BY_ACL = "CombinationMatrix.countCombinationByACL";

   public static final String PARA_ACCESSCONTROL = "accessControl";

   @ManyToOne
   private Reference country;

   @ManyToOne
   private Reference documentType;

   @ManyToOne
   private Reference productType;

   @ManyToOne
   private Reference transactionType;

   @ManyToOne
   private Reference processingCentre;

   @ManyToOne
   private Reference userLocation;

   @OneToMany(mappedBy = "combination")
   private List<CombinationACL> accessControls;

   @ManyToMany(mappedBy = "combinationMatrices", cascade = { CascadeType.PERSIST, CascadeType.MERGE,
         CascadeType.REFRESH })
   private List<Profile> profiles;

   @Size(max = 1000)
   private String description;

   @Enumerated
   private CombinationType combinationType;

   public Reference getCountry() {
      return this.country;
   }

   public void setCountry(Reference country) {
      this.country = country;
   }

   public Reference getDocumentType() {
      return this.documentType;
   }

   public void setDocumentType(Reference documentType) {
      this.documentType = documentType;
   }

   public Reference getProductType() {
      return this.productType;
   }

   public void setProductType(Reference productType) {
      this.productType = productType;
   }

   public Reference getTransactionType() {
      return this.transactionType;
   }

   public void setTransactionType(Reference transactionType) {
      this.transactionType = transactionType;
   }

   public Reference getProcessingCentre() {
      return this.processingCentre;
   }

   public void setProcessingCentre(Reference processingCentre) {
      this.processingCentre = processingCentre;
   }

   public Reference getUserLocation() {
      return this.userLocation;
   }

   public void setUserLocation(Reference userLocation) {
      this.userLocation = userLocation;
   }

   public List<CombinationACL> getAccessControls() {
      return accessControls;
   }

   public void setAccessControls(List<CombinationACL> combinationACLs) {
      this.accessControls = combinationACLs;
   }

   public String getDescription() {
      return this.description;
   }

   public void setDescription(String description) {
      this.description = description;
   }

   public CombinationType getCombinationType() {
      return this.combinationType;
   }

   public void setCombinationType(CombinationType combinationType) {
      this.combinationType = combinationType;
   }

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "id")
   private Long id;

   public Long getId() {
      return this.id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public List<Profile> getProfiles() {
      return profiles;
   }

   public void setProfiles(List<Profile> profiles) {
      this.profiles = profiles;
   }

}
